package norain.wxt.controllers.Authorize;

import com.sun.javafx.scene.layout.region.Margins;
import norain.wxt.formbean.RegisterFormBean;
import norain.wxt.util.WebUtils;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Created by wxt on 16/5/24.
 */
@WebServlet(name = "SignUpServlet")
public class SignUpServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // RegisterFormBean formBean = new RegisterFormBean();
//        formBean.setUserName(request.getParameter("userName")!=null?request.getParameter("userName").toString():"");
//        formBean.setAgree(Boolean.parseBoolean(request.getParameter("isAgree")!=null?request.getParameter("isAgree").toString():"false") );
//        formBean.setEmail(request.getParameter("email")!=null?request.getParameter("email").toString():"");
//        formBean.setPassword(request.getParameter("password")!=null?request.getParameter("password").toString():"");
//
        RegisterFormBean formBean = WebUtils.request2Bean(request, RegisterFormBean.class);


    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        RegisterFormBean formBean = new RegisterFormBean();
        request.setAttribute("formBean", formBean);
        request.getRequestDispatcher("/WEB-INF/ServletViews/Authorize/Register.jsp").forward(request, response);
    }
}
